home *** CD-ROM | disk | FTP | other *** search
- #include "bbs.h"
-
- static int DisplayIt(char *fname)
- {
- int MoreStat,stat,Color = 0;
- char str[200];
- FILE *fp;
-
- if(!(fp=fopen(fname,"r"))) {
- MyError(4); //(RTS) FileListError();
- return(SUCCESS);
- }
-
- /* We should check for the file in ram: if there, show it, if not, copy it */
-
- while(fgets(str,80,fp)!=NULL)
- {
- str[81]='\0';
- if(str[strlen(str)-1]=='\n') {
- if(gnsflag!=1) LineCount++;
- strcat(str,"\r");
- }
-
- if(Color==1)
- AEPutStr("");
- AEPutStr(str);
-
- if(SCheckInput()) {
- stat=ReadChar(1L);
- if(stat<0) {
- fclose(fp);
- return(stat);
- }
- switch(stat) {
- case '\023': /* Pause */
- stat=ReadChar(KEYBOARD_TIMEOUT);
- if(stat<0) {
- fclose(fp);
- return(NO_CARRIER);
- }
- break;
- case '\003': /* ^C */
- fclose(fp);
- AEPutStr("**Break\r\n\r\n");
- return(FAILURE);
- }
- }
- MoreStat=FlagPause(0);
- if(MoreStat<0) {
- fclose(fp);
- return(MoreStat);
- }
- }
- fclose(fp);
- return(SUCCESS);
- }
-
- int DisplayFileList(void)
- {
- int stat,stat2,FLLoop;
- char str[81],ray[200];
- char tempfile[256];
- int fcopy = FALSE;
-
- gnsflag=LineCount=0;
-
- AEPutStr("\r\n");
- if(MaxDirs==0) {
- MyError(5); //Sorry();
- return(FAILURE);
- }
-
- stat2=CommandSplit();
- if(stat2>1)
- stat=GetDirSpan(Command[1]);
- else {
- sprintf(GSTR1,"%sFileHelp",Screen_Location);
- if(!(stat=ChecktoDisplay(GSTR1,GSTR3,0,0)))
- UnAvailNotice(GSTR3,GSTR1);
- stat=GetDirSpan("\0");
- }
-
- if(stat==FAILURE) return(SUCCESS);
-
- gnsflag=CheckForNS(MAINMENU_Li);
-
- FLLoop=StartDir;
- while(FLLoop<=DirScan) {
- strcpy(str,Conference_Location);
- if(DirScan!=(-1)) {
- if(FLLoop == MaxDirs) { /* at upload dir */
- strcat(str,"DIR");
- sprintf(ray,"%d",FLLoop);
- strcat(str,ray);
- sprintf(ray,"Scanning directory %d\r\n",FLLoop);
- AEPutStr(ray);
-
- /* now copy to T: and use T: copy */
- sprintf(tempfile,"T:tdir.%d",Cmds->AcLvl[LVL_NODE_NUMBER]);
- if((FileCopy(str,tempfile))) {
- strcpy(str,tempfile);
- fcopy = TRUE;
- }
- } else {
- strcat(str,"DIR");
- sprintf(ray,"%d",FLLoop);
- strcat(str,ray);
- sprintf(ray,"Scanning directory %d\r\n",FLLoop);
- AEPutStr(ray);
- }
- } else {
- strcat(str,"hold/held");
- AEPutStr("Scanning directory HOLD\r\n");
- }
- stat=FlagPause(1);
- if(stat<0) {
- if(fcopy) DeleteFile(tempfile); //(RTS)
- return(stat);
- }
- stat = DisplayIt(str);
- if(fcopy) {
- DeleteFile(tempfile); //(RTS)
- fcopy = FALSE;
- }
- if(stat==FAILURE) return(SUCCESS);
- if(stat==NO_CARRIER) return(NO_CARRIER);
- if(stat==TIMEOUT) return(stat);
- //if(DirScan == MaxDirs) return(stat);
-
- AEPutStr("\r\n");
- FLLoop+=1;
- }
- if(fcopy) DeleteFile(tempfile); //(RTS)
- return(SUCCESS);
- }
-
-